﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using BusinessLogicLayer;
using DataAccessLayer;

namespace PresentationLayer
{
    public partial class MarketingProgramBackup : Form, IChildForm
    {
        private MarketingProgramBLL marketingProgramBLL;
        DataGridViewComboBoxColumn dgvcbcItemNameID = new DataGridViewComboBoxColumn();

        public ToolStrip ChildToolStrip
        {
            get
            {
                return this.toolStripChildForm;
            }
            set
            {
                this.toolStripChildForm = value;
            }
        }

        public MarketingProgramBackup()
        {
            InitializeComponent();

            #region Add custom tab control

            CustomTabControl customTabMechanicScheme = new CustomTabControl();
            //CustomTabControl customTabItemCategory = new CustomTabControl();
            //CustomTabControl customTabCustomerChannel = new CustomTabControl();

            //TabControl customTabMechanicScheme = new TabControl();
            //TabControl customTabItemCategory = new TabControl();
            //TabControl customTabCustomerChannel = new TabControl();



            //customTabMechanicScheme.ImageList = this.imageList1;
            //customTabItemCategory.ImageList = this.imageList1;
            //customTabCustomerChannel.ImageList = this.imageList1;


            customTabMechanicScheme.DisplayStyle = TabStyle.VisualStudio;

            customTabMechanicScheme.TabPages.Add("MechanicScheme", "Scheme  ", 0);
            customTabMechanicScheme.TabPages[0].Controls.Add(this.dataGridViewMechanicScheme);

            //customTabItemCategory.TabPages.Add("ItemCategory", "Category  ", 0);
            //customTabItemCategory.TabPages[0].Controls.Add(this.dataGridViewItemCategory);

            //customTabCustomerChannel.TabPages.Add("AddressArea", "Territory", 0);
            //customTabCustomerChannel.TabPages[0].Controls.Add(this.dataGridViewAddressArea);
            //customTabCustomerChannel.TabPages.Add("CustomerChannel", "Channel   ", 0);
            //customTabCustomerChannel.TabPages[1].Controls.Add(this.dataGridViewCustomerChannel);
            //customTabCustomerChannel.TabPages.Add("CustomerName", "Customer  ", 0);
            //customTabCustomerChannel.TabPages[2].Controls.Add(this.dataGridViewCustomerName);


            customTabMechanicScheme.Dock = DockStyle.Left;
            //customTabItemCategory.Dock = DockStyle.Fill;
            //customTabCustomerChannel.Dock = DockStyle.Fill;

            this.splitContainerMechanicScheme.Panel1.Controls.Add(customTabMechanicScheme);
            //this.splitContainerItemCategory.Panel1.Controls.Add(customTabItemCategory);
            //this.splitContainerItemCategory.Panel2.Controls.Add(customTabCustomerChannel);




            //this.splitContainer3.Panel2.Controls.Add(customTabMechanicScheme);
            //this.Controls.Add(customTabMechanicScheme);








            #endregion


            marketingProgramBLL = new MarketingProgramBLL();

        }

        private void MarketingProgram_Load(object sender, EventArgs e)
        {



            //DataTable dtableItemName = new DataTable();
            //dtableItemName = ADODatabase.GetDataTable("SELECT * FROM ListItemCategory");
            //if (dtableItemName != null)
            //{
            //    DataRow drow = dtableItemName.NewRow();
            //    drow["ItemCategoryID"] = 0;
            //    dtableItemName.Rows.Add(drow);
            //}
            //dgvcbcItemNameID.Name = "ItemCategoryID";
            //dgvcbcItemNameID.HeaderText = "Item Category";
            //dgvcbcItemNameID.DataPropertyName = "ItemCategoryID";
            //dgvcbcItemNameID.DataSource = dtableItemName;
            //dgvcbcItemNameID.DisplayMember = "Description";
            //dgvcbcItemNameID.ValueMember = "ItemCategoryID";
            //dgvcbcItemNameID.FlatStyle = FlatStyle.Flat;
            //dgvcbcItemNameID.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;// .ComboBox;
            
            

            ////DataGridViewTextBoxColumn dgvtbcUnitPrice = new DataGridViewTextBoxColumn();
            ////dgvtbcUnitPrice.CellTemplate = 
            ////dgvtbcUnitPrice.Name = "UnitPrice";
            ////dgvtbcUnitPrice.HeaderText = "Unit Price";
            ////dgvtbcUnitPrice.DataPropertyName = "UnitPrice";

            //this.dataGridView2.Columns.Add(dgvcbcItemNameID);

            ////this.dataGridView2.EditMode = DataGridViewEditMode.EditOnEnter;




            //this.dataGridView1.DataSource = this.marketingProgramBLL.MarketingProgramMasterList;

            //this.dataGridView2.DataSource = this.marketingProgramBLL.ItemCategoryList;

            //this.textBox1.DataBindings.Add("Text", this.marketingProgramBLL.MarketingProgramMaster, "Reference");

            //this.textBox2.DataBindings.Add("Text", this.marketingProgramBLL.MarketingProgramMaster, "ReferenceCode");

            //this.textBox3.DataBindings.Add("Text", this.marketingProgramBLL.MarketingProgramMaster, "Remarks");

            //this.marketingProgramBLL.MarketingProgramMaster.PropertyChanged += new PropertyChangedEventHandler(MarketingProgramMaster_PropertyChanged);




            











        }

        void MarketingProgramMaster_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            this.button1.Enabled = this.marketingProgramBLL.MarketingProgramMaster.IsDirty;
        }

     


     

        private void dataGridView2_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {


            //if (dataGridView2.CurrentCell.ColumnIndex == 0 && (e.Control is ComboBox)) //.Equals(GenderColumn.Index)
            //{
            //    var genderCombox = e.Control as System.Windows.Forms.ComboBox; // ComboBox
            //    //genderCombox.DropDownStyle = ComboBoxStyle.DropDown;
            //    genderCombox.DroppedDown = true;
            //}




            //    Private Sub YOUR_GRID_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles YOUR_GRID.EditingControlShowing
            //If TypeOf e.Control Is System.Windows.Forms.ComboBox Then
            //With DirectCast(e.Control, System.Windows.Forms.ComboBox)
            //'Set the dropdown style as you like
            //.DropDownStyle = ComboBoxStyle.DropDownList
            //End With
            //Else
            //'The type is either TextBoxColumn/ImageColumn etc..
            //End If
            //End Sub


        }

        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            if (this.dataGridView1.CurrentRow != null)
            {
                this.marketingProgramBLL.MarketingProgramID = int.Parse(dataGridView1.CurrentRow.Cells["MarketingProgramID"].Value.ToString());

            }

            

            //this.splitContainer1.Panel2.Show();
        }

       

    }
}
